The runtime errors occur when an application is running, hence the word "Runtime", this means it will only occur when attempting to run an application or use a specific function within that application. As was mentioned mismatch errors are typically the catalyst. Type Mismatch within the programs code can be the result of a number of things such as data type mismatch, expression mismatch or simply showing type mismatch. In this article type mismatch error occur if the dimension of an object as a Recordset and then set that object to databaseobject.OpenRecordset(source), editor will show type mismatch 13 error as shown in Fig 1.1.
Fig:-1.1
The main cause of this error is wrongly reference of recordset library. If both the libraries are selected already and we are not use the reference in code then this error will come. The object of recordset not determines which library to refer. If we use recordset object without ADO and DAO, then VBA editor return this error.
Dim rs1 As Recordset
Dim rs As Recordset
Resolution:
For resolution we have to use DAO and ADO library reference with recordset object .This error occurs on run time and it depends to your VBA code. We can avoid with this error by referring library with Recordset.
SAMPLE VBA CODE
Option Compare Database Private Sub Form_Load() Dim dbs As Database Dim rs1 As DAO.Recordset Dim rs As ADODB.Recordset Set dbs = CurrentDb Set rs = dbs.OpenRecordset("select * from Table1") End Sub
DISCLAIMER
It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. ERP Makers will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.